﻿Imports Microsoft.Practices.Composite.Modularity
Imports Microsoft.Practices.Unity
Imports Infragistics.Windows.Ribbon
Imports Microsoft.Practices.Composite.Regions
Imports Hinshelwood.TFSStickyBuddy.Infrastructure
Imports Hinshelwood.TFSStickyBuddy.Modules.Interfaces

Imports Hinshelwood.TFSStickyBuddy.Modules.Controllers


'Imports StockTraderRI.Infrastructure.Interfaces
'Imports StockTraderRI.Modules.News.Article
'Imports StockTraderRI.Modules.News.Controllers
'Imports StockTraderRI.Modules.News.Services

Public Class LogInModule
    Implements IModule

    Private ReadOnly m_container As IUnityContainer
    Private ReadOnly m_rmShell As IRegionManager
    Private ReadOnly m_NavigationService As INavigationService

    Public Sub New(ByVal container As IUnityContainer, ByVal regionManager As IRegionManager, ByVal NavigationService As INavigationService)
        m_container = container
        m_rmShell = regionManager
        m_NavigationService = NavigationService
    End Sub


    Public Sub Initialize() Implements Microsoft.Practices.Composite.Modularity.IModule.Initialize
        RegisterViewsAndServices()
        ' Get reference to Controler
        Dim controller As ILogInController = m_container.Resolve(Of ILogInController)()
        ' Start Ball Roaling by adding views to the display
        m_NavigationService.EnsureBaseRegions()
        m_NavigationService.AddButtonTool("Sign In", controller.SignInCommand, Nothing, RegionNames.Shell_Ribbon_HomeTab_HomeGroup)
        m_NavigationService.AddButtonTool("Sign Out", controller.SignOutCommand, Nothing, RegionNames.Shell_Ribbon_HomeTab_HomeGroup)
        ' Attempt to connect to the last state
        'controller.TryConnect()
    End Sub

    Protected Sub RegisterViewsAndServices()
        ' Register Presentation Models
        'm_container.RegisterType(Of IAddRemoveServerPresentationModel, AddRemoveServerPresentationModel)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of IAddServerPresentationModel, AddServerPresentationModel)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of ICredentialProviderPresentationModel, CredentialProviderPresentationModel)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of IConnectToServerPresentationModel, ConnectToServerPresentationModel)(New ContainerControlledLifetimeManager())
        ''m_container.RegisterType(Of IConnectedToPresentationModel, ConnectedToPresentationModel)(New ContainerControlledLifetimeManager())
        ' Register Presenters
        'm_container.RegisterType(Of IAddRemoveServerPresenter, AddRemoveServerPresenter)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of IAddServerPresenter, AddServerPresenter)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of ICredentialProviderPresenter, CredentialProviderPresenter)(New ContainerControlledLifetimeManager())
        'm_container.RegisterType(Of IConnectToServerPresenter, ConnectToServerPresenter)(New ContainerControlledLifetimeManager())
        ''m_container.RegisterType(Of IConnectedToPresenter, ConnectedToPresenter)(New ContainerControlledLifetimeManager())
        ' Register Views
        'm_container.RegisterType(Of IAddRemoveServerView, AddRemoveServerView)()
        'm_container.RegisterType(Of IAddServerView, AddServerView)()
        'm_container.RegisterType(Of ICredentialProviderView, CredentialProviderView)()
        'm_container.RegisterType(Of IConnectToServerView, ConnectToServerView)()
        'm_container.RegisterType(Of IConnectedToView, ConnectedToView)()
        ' Register Services
        'm_container.RegisterType(Of ITeamServerService, TeamServerService)(New ContainerControlledLifetimeManager())
        ' Register Controlers
        m_container.RegisterType(Of ILogInController, LogInController)(New ContainerControlledLifetimeManager())
    End Sub


End Class
